<?php

use App\Models\Auth\User;
use App\Models\Permission\ModuleName;
use App\Models\Permission\Role;
use App\Models\Permission\UserRole;
use App\Models\Permission\Permission;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;

class GenerateSuperadminUser extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up() {
        $user = User::create([
            'first_name' => 'Super Admin',
            'username' => 'superadmin',
            'password' => Hash::make('1234%qwerT'),
        ]);
        $role = Role::create([
            'name' => 'Super Role'
        ]);

        $user->roles()->sync([$role->id]);
        $role->permissions()->sync(Permission::pluck('id'));
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down() {

    }
}
